package com.stylefeng.guns.rest.modular.auth.controller;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.stylefeng.guns.rest.modular.auth.util.HttpKit;

/**
 * 请求验证的
 *
 * @author shaohaiting
 * @Date 2018/6/27 10:52
 */
@RestController
public class JweController {
	
    @RequestMapping(value = "jwe")
    public Object jwe(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String url = req.getHeader("url");
        System.out.println(url);
        Map<String, String> map = HttpKit.getRequestParameters();
//        String s = req.getParameter("jwe");
//        System.out.println("req:"+s);
//        Map<String, String> map1 = new HashMap<>();
        System.out.println("map:"+map.toString());
//        map1.put("jwe", s);
        String res = HttpKit.sendPost("http://xmock.dl.alipaydev.com/api/Test/TestGroup/fengbotest/jwe-encoder.htm", map);
        System.out.println("res:"+res);
        Map<String, String> map2 = new HashMap<>();
        map2.put("jwe", res);
        String res2 = HttpKit.sendPost(url, map2);
        System.out.println("res2:"+res2);
        Map<String, String> map3 = new HashMap<>();
        map3.put("jwe", res2);
        String res3 = HttpKit.sendPost("http://xmock.inc.alipay.net/api/Test/TestGroup/fengbotest/jwe-decoder.htm", map3);
        System.out.println("res3:"+res3);
        return res3;
    }
}
